<table>
    <tr>
        <td colspan="6">
            <?php echo $this->element('excel/title'); ?>
        </td>
        <td colspan="6">
            <table>
                <tr>
                    <td colspan="6" class="docNote">VMI: CUSTOMER INVENTORY</td>
                </tr>
                <tr>
                    <td><label>Printed Date</label></td>
                    <td><?php echo date('d/m/Y H:i'); ?></td>
                    <td><label>Page</label></td>
                    <td><span class="pageNo">1/1</span></td>
                </tr>
                <tr>
                    <td><label>Printed by</label></td>
                    <td colspan="3"><?php echo $report_by; ?></td>
                </tr>
                <tr>
                    <td width="90px"><label>Customer no.</label></td>
                    <td colspan="3"><?php echo $customer_no; ?></td>
                </tr>
                <tr>
                    <td><label>Customer name</label></td>
                    <td colspan="3"><?php echo $customer_name; ?></td>
                </tr>
                <tr>
                    <td width="90px"><label>Site no.</label></td>
                    <td colspan="3"><?php echo $site_no; ?></td>
                </tr>
                <tr>
                    <td><label>Site Name</label></td>
                    <td colspan="3"><?php echo $site_name; ?></td>
                </tr>
                <?php if ($session->check('Criteria.dispatch_from')) {
                ?>
                    <tr>
                        <td><label>Vendor</label></td>
                        <td colspan="3"><?php echo $session->read('Criteria.dispatch_from'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.brand_name')) {
                ?>
                    <tr>
                        <td><label>Brand</label></td>
                        <td colspan="3"><?php echo $session->read('Criteria.brand_name'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.category_name')) {
                ?>
                    <tr>
                        <td><label>Category</label></td>
                        <td colspan="3"><?php echo $session->read('Criteria.category_name'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.stock_code')) {
                ?>
                    <tr>
                        <td><label>Stock Code</label></td>
                        <td colspan="3"><?php echo $session->read('Criteria.stock_code'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.part_no')) {
                ?>
                    <tr>
                        <td><label>Vendor Part no.</label></td>
                        <td colspan="3"><?php echo $session->read('Criteria.part_no'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.title')) {
                ?>
                    <tr>
                        <td><label>Description</label></td>
                        <td colspan="3"><?php echo $session->read('Criteria.title'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.current_stock')) {
                ?>
                    <tr>
                        <td><label>Current Stock</label></td>
                        <td colspan="3"><?php echo $session->read('Operand.current_stock') . ' ' . $session->read('Criteria.current_stock'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.min_stock')) {
                ?>
                    <tr>
                        <td><label>Min Stock</label></td>
                        <td colspan="3"><?php echo $session->read('Operand.min_stock') . ' ' . $session->read('Criteria.min_stock'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.max_stock')) {
                ?>
                    <tr>
                        <td><label>Max Stock</label></td>
                        <td colspan="3"><?php echo $session->read('Operand.max_stock') . ' ' . $session->read('Criteria.max_stock'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.reserve_qty')) {
                ?>
                    <tr>
                        <td><label>Reserved Qty</label></td>
                        <td colspan="3"><?php echo $session->read('Operand.reserve_qty') . ' ' . $session->read('Criteria.reserve_qty'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.last_stock_in_date_start')) {
                ?>
                    <tr>
                        <td><label>Last Stock in Date</label></td>
                        <td colspan="3">From <?php echo $session->read('Criteria.last_stock_in_date_start'); ?> To <?php echo $session->read('Criteria.last_stock_in_date_end'); ?></td>
                    </tr>
                <?php } ?>
                <?php if ($session->check('Criteria.last_stock_out_date_start')) {
                ?>
                    <tr>
                        <td><label>Last Stock out Date</label></td>
                        <td colspan="3">From <?php echo $session->read('Criteria.last_stock_out_date_start'); ?> To <?php echo $session->read('Criteria.last_stock_out_date_end'); ?></td>
                    </tr>
                <?php } ?>
            </table>
        </td>
    </tr>
</table>

<div class="main">
    <table id="dataTable" class="dataTable" cellspacing="0" cellpadding="0" >
        <thead id="tableHead">
            <tr>
                <th class="no">No</th>
                <th>Stock Code</th>
                <th>Vendor Part no.</th>
                <th>Category</th>
                <th>Brand</th>
                <th>Model</th>
                <th>Description</th>
                <th>Location</th>
                <th width="100px">Current Stock</th>
                <th width="100px">Reserved Qty</th>
                <th width="80px">Min Stock</th>
                <th width="80px">Max Stock</th>
            </tr>
        </thead>
        <tbody id="tableBody">
            <?php
                foreach ($this->data as $i => $data) :
                    $current_stock = $data['CustProductSite']['current_stock'];
                    $min_stock = $data['CustProductSite']['min_stock'];
                    $max_stock = $data['CustProductSite']['max_stock'];
            ?>
                    <tr class="row">
                        <td class="center rowTd"><?php echo $i + 1; ?></td>
                        <td><?php echo $data['CustProductSite']['stock_code']; ?></td>
                        <td><?php echo $data['CustProductSite']['dispatch_from'] == ITS_PREFIX ? $data['Product']['part_no'] : $data['Product']['supplier_part_no']; ?></td>
                        <td><?php echo isset($data['Product']['Category']['name']) ? $data['Product']['Category']['name'] : '-'; ?></td>
                        <td><?php echo $data['Product']['Brand']['name']; ?></td>
                        <td><?php echo $data['Product']['model']; ?></td>
                        <td><?php echo!empty($data['CustProductSite']['text']) ? $data['CustProductSite']['text'] : $data['Product']['text']; ?></td>
                        <td><?php echo isset($data['ProductSerial'][0]) && isset($data['ProductSerial'][0]['CustLocation']['name'])? $data['ProductSerial'][0]['CustLocation']['name']: '-'; ?></td>
                        <td class="text-right">
                    <?php echo $current_stock; ?>
                </td>
                <td class="text-right">&nbsp;<?php echo $data['CustProductSite']['reserve_qty']; ?></td>
                <td class="text-right">&nbsp;<?php echo $data['CustProductSite']['min_stock']; ?></td>
                <td class="text-right">&nbsp;<?php echo $data['CustProductSite']['max_stock']; ?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>

<div class="footer"></div>

<div id="divLastFooter">
</div>